package com.zzyl.nursing.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzyl.nursing.domain.ElderMember;
import com.zzyl.nursing.mapper.ElderMemberMapper;
import com.zzyl.nursing.service.IElderMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 老人和家属(客户)关联Service业务层处理
 * 
 * @author itheima
 * @date 2025-03-18
 */
@Service
public class ElderMemberServiceImpl extends ServiceImpl<ElderMemberMapper, ElderMember> implements IElderMemberService
{
    @Autowired
    private ElderMemberMapper elderMemberMapper;

    /**
     * 查询老人和家属(客户)关联
     * 
     * @param id 老人和家属(客户)关联主键
     * @return 老人和家属(客户)关联
     */
    @Override
    public ElderMember selectElderMemberById(Long id)
    {
        return getById(id);
    }

    /**
     * 查询老人和家属(客户)关联列表
     * 
     * @param elderMember 老人和家属(客户)关联
     * @return 老人和家属(客户)关联
     */
    @Override
    public List<ElderMember> selectElderMemberList(ElderMember elderMember)
    {
        return elderMemberMapper.selectElderMemberList(elderMember);
    }

    /**
     * 新增老人和家属(客户)关联
     * 
     * @param elderMember 老人和家属(客户)关联
     * @return 结果
     */
    @Override
    public int insertElderMember(ElderMember elderMember)
    {
        return save(elderMember) ? 1 : 0;
    }

    /**
     * 修改老人和家属(客户)关联
     * 
     * @param elderMember 老人和家属(客户)关联
     * @return 结果
     */
    @Override
    public int updateElderMember(ElderMember elderMember)
    {
        return updateById(elderMember) ? 1 : 0;
    }

    /**
     * 批量删除老人和家属(客户)关联
     * 
     * @param ids 需要删除的老人和家属(客户)关联主键
     * @return 结果
     */
    @Override
    public int deleteElderMemberByIds(Long[] ids)
    {
        return removeByIds(Arrays.asList(ids)) ? 1 : 0;
    }

    /**
     * 删除老人和家属(客户)关联信息
     * 
     * @param id 老人和家属(客户)关联主键
     * @return 结果
     */
    @Override
    public int deleteElderMemberById(Long id)
    {
        return removeById(id) ? 1 : 0;
    }
}
